/**
 * Copyright (c) 2009-2011, chunquedong(YangJiandong)
 * 
 * This file is part of ChunMap project
 * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE(Version >=3)
 * 
 * History:
 *     2010-05-05  Jed Young  Creation
 */
package chunmap.data.feature;

import chunmap.data.provider.DataSource;
import chunmap.model.elem.Envelope;
import chunmap.model.elem.EnvelopeBuf;

public abstract class FeatureSet implements FeatureCollection{
	private Envelope envelope;
	private DataSource dataResources ;
	private LayerMetadata metadata ;
	private FeatureSchama featureSchama;

    public Envelope getEnvelope() {
		return envelope;
	}
	public void setEnvelope(Envelope envelope) {
		this.envelope = envelope;
	}
	public DataSource getDataResources() {
		return dataResources;
	}
	public void setDataResources(DataSource dataResources) {
		this.dataResources = dataResources;
	}
	public LayerMetadata getMetadata() {
		return metadata;
	}
	public void setMetadata(LayerMetadata metadata) {
		this.metadata = metadata;
	}
	public FeatureSchama getFeatureSchama() {
		return featureSchama;
	}
	public void setFeatureSchama(FeatureSchama featureSchama) {
		this.featureSchama = featureSchama;
	}
	
	public abstract void insert(Feature f);
    public abstract boolean remove(Feature f);
    public abstract void search(Envelope envelope, VisitFunc filter);
    public abstract void select(Envelope envelope, VisitAction filter);
    public abstract void find(VisitFunc filter);
    public abstract void each(VisitAction filter);

    //#endregion

    public void reComputeEnvelope()
    {
        final EnvelopeBuf eb = new EnvelopeBuf();
        this.each(new VisitAction(){
			@Override
			public void execute(Feature f) {
				eb.mergeEnvelop(f.getEnvelop());
			}});
        envelope = eb.toEnvelop();
    }
}